class MyPromise {
  status: "pending" | "rejected" | "resolved";
  onResolvedCbs: [] | ((...args: any) => any|void)[];
  onRejectedCbs: [] | ((...args: any) => any|void)[];
  reason: any;
  value: any;
  constructor (func) {
    this.status = 'pending'
    this.onResolvedCbs = []
    this.onRejectedCbs = []
    try{
      func(this.resolve.call(this), this.reject.call(this))
    }catch(err){
      this.reject(err)
    }
  }
  resolve(value: any) {
    this.status = 'resolved'
    this.value = value
  }
  reject(reason) {
    this.status = 'rejected'
    this.reason = reason
  }
  then(onResolved, onRejected) {
    return new Promise((resolve, reject)=>{
      if (this.status === "pending") {
        this.onResolvedCbs.push(()=>{

        })  
      }
    })  
  }
  resolvePromise() {}
}